<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      .container {
        width: 100%;
        height: 400px;
        /* 1. flex */
        /* display: flex;
        justify-content: center;
        align-items: center; */
        /* 2. 定位 */
        position: relative;
      }
      .box {
        width: 100px;
        height: 100px;
        background-color: yellowgreen;
        position: absolute;
        left: 50%;
        top: 50%;
        /* transform: translate(-50%, -50%); */
        margin-left: -50px;
        margin-top: -50px;
      }
    </style>
  </head>
  <body>
    <!-- 
      1. flex
      2. 定位
      3. 文本垂直居中
        text-align: center
        line-height: 容器高度
    -->
    <div class="container">
      <div class="box"></div>
    </div>
  </body>
</html>
